{include file="header"}
<!--<div class="x-nav">-->
<!--             <span class="layui-breadcrumb">-->
<!--            <a href="">{:lang("system")}</a>-->
<!--            <a href="">TV管理</a>-->
<!--            <a href="">TV列表</a>-->
<!--            <a>-->
<!--              <cite>添加剧集</cite></a>-->
<!--          </span>-->

<!--</div>-->
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this"><span style="font-size: 16px">基本信息</span></li>
                    <li><span style="font-size: 16px">制作人员表</span> / 人物设计 キャラクタ</li>
                    <li><span style="font-size: 16px">声优</span></li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>话数
                            </label>
                            <div class="layui-input-block" >
                                <input type="radio" name="number_type" lay-filter="number_type" value="1" title="季番" checked>
                                <input type="radio" name="number_type" lay-filter="number_type" value="2" title="常规">
                                <input type="radio" name="number_type" lay-filter="number_type" value="3" title="特殊">
                            </div>
                            <div class="layui-input-block" style="display: flex">
                                <div style="display:none" id="number_desc_type">
                                    <select name="number_type_special" lay-filter="number_desc_type">
                                        <option value ="1">浓缩</option>
                                        <option value ="2">电影</option>
                                        <option value ="3">OVA</option>
                                    </select>
                                </div>
                            <input type="text" name="number_desc" id="number_desc" style="width: 300px;" autocomplete="off" class="layui-input" value="第__季 第__话">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>标题（中文）
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="name_cn" placeholder="{:lang('please.enter')}标题（中文）" autocomplete="off" class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>标题（日文）
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="name_rw" placeholder="{:lang('please.enter')}标题（日文）" autocomplete="off" class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>首更日期
                            </label>
                            <div class="layui-input-block" style="width: 300px; display: flex">
                                <input type="text" name="first_date" id="first_date" placeholder="请选择首更日期" autocomplete="off" class="layui-input" value="">
                                <input type="hidden" name="first_date_week" id="first_date_week" autocomplete="off" class="layui-input" value="" disabled>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>播出电视台
                            </label>
                            <div class="layui-input-block">
                                <input type="text" name="broadcast_tv" placeholder="{:lang('please.enter')}播出电视台" autocomplete="off" class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>剧集长度
                            </label>
                            <div class="layui-input-block" style="width:300px;display: flex">
                                <select id="drama_length" name="drama_length" lay-filter="drama_length">
                                    <option value ="1">常规25分钟</option>
                                    <option value ="2">特别篇</option>
                                </select>
                                <input type="hidden" name="drama_length_msg" id="drama_length_msg" class="layui-input" value="__小时特别篇">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>剧集类型
                            </label>
                            <div class="layui-input-block" style="width:300px; display: flex">
                                <select id="drama_type" name="drama_type" lay-filter="demo1">
                                    <option value ="1">原作漫改</option>
                                    <option value ="2">动画组原创</option>
                                    <option value ="3">停播</option>
                                    <option value ="4">重播</option>
                                </select>
                                <div style="display:none" id="div_cb">
                                    <select id="drama_replay_type" name="drama_replay_type">
                                        <option value ="1">原作漫改</option>
                                        <option value ="2">动画组原创</option>
                                        <option value ="3">电影</option>
                                        <option value ="4">OVA</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                                <span class="x-red">*</span>漫画
                            </label>
                            <div class="layui-input-block" style="display: flex">
                                <label class="layui-form-label">
                                    <span class="x-red"></span>总话数
                                </label>
                                <input type="text" name="comics_total" id="comics_total" style="width: 250px;" placeholder="{:lang('please.enter')}总话数" autocomplete="off" class="layui-input" value="File.__~__或File.__">
                                <label class="layui-form-label">
                                    <span class="x-red"></span>单行本话数
                                </label>
                                <input type="text" name="comics_single" id="comics_single" style="width: 360px;" placeholder="{:lang('please.enter')}单行本话数" autocomplete="off" class="layui-input" value="第__卷 File.__~ 第__卷 File.__ 或 第___卷 File.__">
                            </div>
                        </div>
                    </div>
                    <!--                  第二部分内容                   -->
                    <div class="layui-tab-item">
                        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                            <ul class="layui-tab-title">
                                <li class="layui-this"><span style="font-size: 14px">正片</span></li>
                                <li><span style="font-size: 14px">OP（オープニング）</span></li>
                                <li><span style="font-size: 14px">ED（エンディング）</span></li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>导演 / 監督
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="director" id="director" placeholder="{:lang('please.enter')}导演 / 監督" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>编剧 / 脚本
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="screenwriter" id="screenwriter" placeholder="{:lang('please.enter')}编剧 / 脚本" autocomplete="off" class="layui-input" >
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>构成
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="constitute" id="constitute" placeholder="{:lang('please.enter')}构成" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>分镜
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="storyboard" id="storyboard" placeholder="{:lang('please.enter')}分镜" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>演出
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="show" id="show" placeholder="{:lang('please.enter')}演出" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>作画导演
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="paint_director" id="paint_director" placeholder="{:lang('please.enter')}作画导演" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>作画监修
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="paint_supervisor" id="paint_supervisor" placeholder="{:lang('please.enter')}作画监修" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>作画导演助理
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="paint_director_zl" id=painting_director_zl" placeholder="{:lang('please.enter')}作画导演助理" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>总作画导演
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="total_paint" id="total_paint" placeholder="{:lang('please.enter')}总作画导演" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>角色设计
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="role" id="role" placeholder="{:lang('please.enter')}角色设计" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>副角色设计
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="role_two" id="role_two" placeholder="{:lang('please.enter')}副角色设计" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>色彩设计
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="color_design" id="color_design" placeholder="{:lang('please.enter')}色彩设计" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>色指定
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="color_specify" id="color_specify" placeholder="{:lang('please.enter')}色指定" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>原画
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="original_painting" id="original_painting" placeholder="{:lang('please.enter')}原画" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>编号
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_number" id="op_number" placeholder="{:lang('please.enter')}编号" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>曲名
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_song_name" id="op_song_name" placeholder="{:lang('please.enter')}曲名" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>歌手(组合)
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_singer" id="op_singer" placeholder="{:lang('please.enter')}歌手(组合)" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>OP分镜（日文：OP絵コンテ）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_storyboard" id="op_storyboard" placeholder="{:lang('please.enter')}OP分镜（日文：OP絵コンテ）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>OP演出（日文：OP演出）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_show" id="op_show" placeholder="{:lang('please.enter')}OP演出（日文：OP演出）" autocomplete="off" class="layui-input" >
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>OP作画导演（日文：OP作画監督）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_paint_director" id="op_paint_director" placeholder="{:lang('please.enter')}OP作画导演（日文：OP作画監督）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>OP总作画导演（日文：OP総作画監督）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_total_paint" id="op_total_paint" placeholder="{:lang('please.enter')}OP总作画导演（日文：OP総作画監督）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>OP原画（日文：OP原画）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="op_original_painting" id="op_original_painting" placeholder="{:lang('please.enter')}OP原画（日文：OP原画）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-tab-item">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>编号
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_number" id="ed_number" placeholder="{:lang('please.enter')}编号" autocomplete="off" class="layui-input">
                                        </div>
                                    </div><div class="layui-form-item">
                                    <label class="layui-form-label">
                                        <span class="x-red">*</span>曲名
                                    </label>
                                    <div class="layui-input-block" >
                                        <input type="text" name="ed_song_name" id="ed_song_name" placeholder="{:lang('please.enter')}曲名" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>歌手(组合)
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_singer" id="ed_singer" placeholder="{:lang('please.enter')}歌手(组合)" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>ED分镜（日文：ED絵コンテ）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_storyboard" id="ed_storyboard" placeholder="{:lang('please.enter')}ED分镜（日文：ED絵コンテ）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>ED演出（日文：ED演出）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_show" id="ed_show" placeholder="{:lang('please.enter')}ED演出（日文：ED演出）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>ED作画导演（日文：ED作画監督）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_paint_director" id="ed_paint_director" placeholder="{:lang('please.enter')}ED作画导演（日文：ED作画監督）" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>ED总作画导演（日文：ED総作画監督）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_total_paint" id="ed_total_paint" placeholder="{:lang('please.enter')}ED总作画导演（日文：ED総作画監督）" autocomplete="off" class="layui-input" >
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">
                                            <span class="x-red">*</span>ED原画（日文：ED原画）
                                        </label>
                                        <div class="layui-input-block" >
                                            <input type="text" name="ed_original_painting" id="ed_original_painting" placeholder="{:lang('please.enter')}ED原画（日文：ED原画）" autocomplete="off" class="layui-input" >
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </div>
                        </div>
                    <!--            第三部分内容                    -->
                    <div class="layui-tab-item">
                        <div class="layui-form-item" id="add_info">
                            <div class="layui-input-block" style="display: flex;">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>角色名(中文|日文)
                                </label>
                                <input type="text" name="character" style="width: 250px;" placeholder="{:lang('please.enter')}角色名" autocomplete="off" class="layui-input" value="">
                                <input type="text" name="character_rw" style="width: 250px;" placeholder="{:lang('please.enter')}日文角色名" autocomplete="off" class="layui-input" value="">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>声优(中文|日文)
                                </label>
                                <input type="text" name="seiyuu" style="width: 250px;" placeholder="{:lang('please.enter')}声优" autocomplete="off" class="layui-input" value="">
                                <input type="text" name="seiyuu_rw" style="width: 250px;" placeholder="{:lang('please.enter')}日文声优" autocomplete="off" class="layui-input" value="">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button" class="layui-btn layui-btn-sm" onclick="add_info_sy()"><i class="layui-icon"></i></button>
                            </div>
                        </div>
                        <!--                提交                     -->
                        <div class="layui-form-item">
                            <label class="layui-form-label">
                            </label>
                            <button  class="layui-btn" lay-filter="add" lay-submit="">
                                {:lang('add')}
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" name="pid" value="{$pid}">
        </form>
    </div>
</div>
{include file="footer"}
<script>
    function add_info_sy(){
        var html = `<div class="layui-input-block" style="display: flex;">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>角色名(中文|日文)
                                </label>
                                <input type="text" name="character" style="width: 250px;" placeholder="{:lang('please.enter')}角色名" id="number_desc" autocomplete="off" class="layui-input" value="">
                                <input type="text" name="character_rw" style="width: 250px;" placeholder="{:lang('please.enter')}日文角色名" id="number_desc" autocomplete="off" class="layui-input" value="">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>声优(中文|日文)
                                </label>
                                <input type="text" name="seiyuu" style="width: 250px;" placeholder="{:lang('please.enter')}声优" id="number_desc" autocomplete="off" class="layui-input" value="">
                                <input type="text" name="seiyuu_rw" style="width: 250px;" placeholder="{:lang('please.enter')}日文声优" id="number_desc" autocomplete="off" class="layui-input" value="">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<!--                                <button type="button" class="layui-btn layui-btn-sm" onclick="del_info_sy"><i class="layui-icon"></i></button>-->
                            </div>`;
        $('#add_info').append(html);
    }
    layui.use(['form', 'layer','laydate'], function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        <!--    时间选择器渲染        -->
        var laydate = layui.laydate;
        //时间筛选
        laydate.render({
            elem: '#first_date',
            done:function(value, date, endDate) {
                $("#first_date_week").attr('type','text');
                var dt = new Date(value);
                switch (dt.getDay()){
                    case 0:
                        $("#first_date_week").val("星期日");
                        break;
                    case 1:
                        $("#first_date_week").val("星期一");
                        break;
                    case 2:
                        $("#first_date_week").val("星期二");
                        break;
                    case 3:
                        $("#first_date_week").val("星期三");
                        break;
                    case 4:
                        $("#first_date_week").val("星期四");
                        break;
                    case 5:
                        $("#first_date_week").val("星期五");
                        break;
                    case 6:
                        $("#first_date_week").val("星期六");
                        break;
                }
                var element = document.getElementById("first_date_week");
                element.style.display = ""; //让元素显示
            }
        });<!--    end        -->

        <!--     话数操作       -->
        form.on('radio(number_type)', function(data){
            switch (data.value){
                case "1":
                    $('#number_desc').val("第__季 第__话");
                    var element = document.getElementById("number_desc_type");
                    element.style.display = "none" //让元素隐藏
                    break;
                case "2":
                    $('#number_desc').val("第__话");
                    var element = document.getElementById("number_desc_type");
                    element.style.display = "none" //让元素隐藏
                    break;
                case "3":
                    var element = document.getElementById("number_desc_type");
                    element.style.display = "" //让元素显示
                    $('#number_desc').val("第__话~第__话");
                    break;
            }
        });
        form.on('select(number_desc_type)', function(data){
            switch (data.value){
                case "1":
                    $('#number_desc').val("第__话~第__话");
                    break;
                case "2":
                    $('#number_desc').val("第__部");
                    break;
                case "3":
                    $('#number_desc').val("第__部");
                    break;
            }
        });
        <!--    END        -->

        <!--    监听剧集类型操作开始        -->
        form.on('select(demo1)', function(data){
            if(data.value == 4){
                var element = document.getElementById("div_cb");
                element.style.display = "" //让元素显示
            }else{
                var element = document.getElementById("div_cb");
                element.style.display = "none" //让元素隐藏
            }
        });
        <!--    END        -->

        <!--    监听剧集长度操作开始        -->
        form.on('select(drama_length)', function(data){
            if(data.value == 2){
                $('#drama_length_msg').attr('type','text');
            }else{
                $('#drama_length_msg').attr('type','hidden');
            }
        });
        <!--    END        -->

        //监听提交
        form.on('submit(add)', function(data) {
            var new_arr = [];
            var character=[];
            var character_rw=[];
            var seiyuu=[];
            var seiyuu_rw=[];
            let obj
            $("[name='character']").each(function () {
                character.push($(this).val())
            })
            $("[name='character_rw']").each(function () {
                character_rw.push($(this).val())
            })
            $("[name='seiyuu']").each(function () {
                seiyuu.push($(this).val())
            })
            $("[name='seiyuu_rw']").each(function () {
                seiyuu_rw.push($(this).val())
            })
            for(let i = 0; i < character.length; i++) {
                 obj = {
                    character: character[i],
                    character_rw: character_rw[i],
                    seiyuu:seiyuu[i],
                    seiyuu_rw:seiyuu_rw[i],
                    pid:data.field.pid,

                }
                new_arr.push(obj);
            }
            data.field.seiyuu_arr = new_arr;
            request("POST",'{:url("television/dramaadd")}',data.field,function (res,msg) {
                //发异步，把数据提交给php
                layer.alert(msg, {icon: 6}, function() {
                    xadmin.close();
                    // 可以对父窗口进行刷新
                    xadmin.father_reload();
                });
            })
            return false;
        });

    });
</script>